package com.ruoyi.salary.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.salary.domain.EmployeeSalary;
import com.ruoyi.salary.services.ISysSalaryService;
import com.ruoyi.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/salary")
public class SysSalaryController extends BaseController {
    @Autowired
    private ISysSalaryService sysSalaryService;

    /**
     * 获取参数配置列表
     */
//    @RequiresPermissions("system:salary:query")
    @GetMapping("/list")
    public TableDataInfo list(EmployeeSalary salary)
    {
        startPage();
        List<EmployeeSalary> list = sysSalaryService.selectSalary(salary);
        return getDataTable(list);
    }

    /**
     * 获取参数配置列表
     * @param salary
     * @return
     */
//    @RequiresPermissions("system:salary:query")
    @GetMapping("/DuplistTest")
    public TableDataInfo DuplistTest(EmployeeSalary salary)
    {


        startPage();

        List<EmployeeSalary> list = sysSalaryService.selectSalary(salary);
        if (!list.isEmpty()) {
            throw new NullPointerException("列表 大小为 ：" + list.size());
        }
        /*
          while true
         */
        boolean flag = true;
        while(flag){
            return getDataTable(list);
        }
        int i =1 ;

        /*
          while death loop
         */
        while( i > 0){
            System.out.println("while death loop");
        }

        /*
          for death loop
         */
        for (; i >= 0; i++) {
            System.out.println(list);
        }

        /*
            add SysUser test
         */
        SysUser user = new SysUser();
        user.setEmail("87468758767@qq.com");
        user.setNickName("ffdcghijk223");
        user.setPassword("ffsdsd");
        user.setAvatar("dfd");
        /*
          array out of index error
         */
        Integer[] arr = {1,2,3};
        System.out.println(arr[3]);

        /*
          null pointer
         */
        String s = null;
        System.out.println(s.length());

        /*
          cast type error
         */
        Number num = 3;
        Double d = (Double) num;
        Double e = (Double) num;

        String s0 = null;
        String s1 = s0 + "error info display 0";
        String s2 = s1 + "error info display 1";
        String s3 = s2 + "error info display 2";
        String s4 = s3 + "error info display 3";

        List<EmployeeSalary> list1 = sysSalaryService.selectSalary(salary);
        List<EmployeeSalary> list2 = sysSalaryService.selectSalary(salary);
        List<EmployeeSalary> list3 = sysSalaryService.selectSalary(salary);
        List<EmployeeSalary> list5 = sysSalaryService.selectSalary(salary);
        List<EmployeeSalary> list4 = sysSalaryService.selectSalary(salary);
        return getDataTable(list);
    }
}
